package com.cat.dataStructure03;

import java.util.HashSet;
import java.util.Set;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/count-number-of-distinct-integers-after-reverse-operations/
 * @create 2025/11/13 11:10
 * @since JDK17
 */

public class Solution51 {
    int reverse(int num) {
        int ans = 0;
        while (num != 0) {
            ans = ans * 10 + num % 10;
            num /= 10;
        }
        return ans;
    }
    public int countDistinctIntegers(int[] nums) {
        int n = nums.length;
        Set<Integer> set = new HashSet<>();
        for (var x : nums) {
            set.add(x);
            set.add(reverse(x));
        }

        return set.size();
    }
}
